public class _3longestOnes {
    //最大连续 1 的个数
    public int longestOnes(int[] nums, int k) {
        int left = 0, right = 0 , len = 0, count = 0,n = nums.length;
        while(right < n){
            if(nums[right] == 0){
                count++;
            }
            while(count > k){
                if(nums[left++] == 0){
                    count--;
                }
            }
            len = Math.max(len,right - left + 1);
            right++;
        }
        return len;
    }
}
